<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>底盘部件信息</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
    <script type="text/javascript" src="../../script/jquery-1.10.2.min.js"></script>
    <style>
        header{ background-color: #FCFCFC; line-height: 42px; height: 42px; position: relative; }
        header b{ width: 42px; height: 100%; display: inline-block; position: relative; z-index: 1; background: url() no-repeat center; background-size: 70% auto;  }
        header b.ic-back{ background-image: url(../../image/ic-back.png); }
        header b.ic-check{ background-image: url(../../image/ic-check.png); float: right; }
        header .title{ position: absolute; left: 0; bottom: 0; right: 0;  text-align: center; font-size: 18px;  }
    </style>
</head>
<body>
    <div id="wrap" class="flex-wrap flex-vertical" >
        <header class="border-b" >
            <b tapmode="hover" onclick="api.closeWin();" class="ic-back"></b>
            <div class="title">检验项目列表</div>
            <b tapmode="hover"  class="ic-check"></b>
        </header>
        <div style="width: 100%; height:42px;"></div>
        <div id="main" class="flex-con"> 
        </div>
    </div>
</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
    apiready = function(){
        $api.fixStatusBar( $api.dom('header'));
         GetButtonList();
        api.openFrame({
            name: 'frm_dpjyxm',
            url: './frm_dpjyxm.html',
            rect: {
                x: 0, 
                y: $api.dom('header').offsetHeight + 42, 
                w: api.winWidth, 
                h: $api.dom('#main').offsetHeight
            },
            bounces : false,
            pageParam: {
                ID: api.pageParam.ID,
                PlateNum: api.pageParam.PlateNum,
                VIN: api.pageParam.VIN,
                HPZL: api.pageParam.HPZL
           }
        });
    };

    //初始化按钮
    function InitButtons(data)
    {
        if(data != null && data.length != 0)
        {
            var vData = new Array([data.length]);
            for (i = 0; i < data.length; i++) {
                vData[i] = {
                    title: data[i]
                }
            }

            var NVNavigationBar = api.require('NVNavigationBar');
            NVNavigationBar.open({
                rect: {
                     x: 0,
                     y: $api.dom('header').offsetHeight,
                     w: api.frameWidth,
                     h: 42
                },
               styles: {
                     orientation: 'horizontal',
                     bg: '#6b6b6b',
                     bgAlpha: 1,
                     font: {
                     size: 14,
                     sizeSelected: 18,
                     color: '#FFFFFF',
                     colorSelected: '#ff0000',
                     alpha: 1
                     },
                     itemSize: {
                         w: 90,
                         h: 42
                     }
               },
                id: 'first',
                items: vData,
                selectedIndex: 0,
                fixedOn: api.frameName
            }, function(ret, err) {
                if (ret.eventType == "click") 
                {
                    var vLineNum = $api.getStorage('LineNum');
                    //alert(vLineNum);
                    SendLEDInfo(vLineNum,ret.index);
                }
            });
        }
    }

    //按钮列表
    function GetButtonList()
    {
        var vUrlRead = $api.getStorage('ServerUrlRead');
         api.ajax({
            url:vUrlRead + '/WcfServices/GetDPBJButtons',
            method: 'post',
            contentType: "application/json",
        }, function(ret, err) {
            if (ret.IsSuccess) {
                InitButtons(ret.Data);
            }
        });
    }

    //发送LED内容
    function SendLEDInfo(jcxdh,iIndex)
    {
        var vID = api.pageParam.ID;
        var vUrlWrite = $api.getStorage('ServerUrlWrite');
         api.ajax({
            url:vUrlWrite + '/WcfServices/SendDGInfo/'+ vID +'/' + jcxdh + '/' + iIndex,
            method: 'post',
            contentType: "application/json",
        }, function(ret, err) {
            if (ret.IsSuccess == false) {
                alert('发送LED内容失败,' + ret.Message);
            } 
        });
    }
</script>